import React from 'react'
import PropTypes from 'prop-types';
//形参的名字自定义
export default function PropsCom(props) {
  return (
    <div>
      <ul>
        <li>姓名: {props.name}</li>
        <li>年龄: {props.age}</li>
        <li>性别: {props.gender}</li>
      </ul>
    </div>
  )
}

//约束组件外部传入属性值的类型
PropsCom.propTypes = {
  name: PropTypes.string.isRequired,
  age: PropTypes.number,
  gender: PropTypes.string
}

//设置属性的默认值
PropsCom.defaultProps = {
  name: '张三'
}

